package com.ymttest.database.sqlwapper;

import java.util.Date;
import java.util.List;
import java.util.Map;

import org.apache.commons.collections.map.HashedMap;

import com.ymt.database.SqlManager;
import com.ymttest.database.model.YmtSellerPromotion;

public class YmtSellerPromotionIMapper {
	SqlManager manage;

	public YmtSellerPromotionIMapper() {
		manage = new SqlManager("YmtMarketing");
	}

	/*
	 * 根据促销ID获取促销信息
	 */
	public List<YmtSellerPromotion> selectPromotionByPromotionId(Integer promotionId) throws InterruptedException {
	    @SuppressWarnings("unchecked")
	    List<YmtSellerPromotion>   promotions = manage.getSelectResults(
	            "com.ymttest.database.mapping.YmtSellerPromotionMapper.selectPromotionByPromotionId", promotionId);
	    manage.commit();
	    return promotions;
	}
	
	/*
	 * 根据买手ID获取促销活动ID
	 */
	public List<YmtSellerPromotion> selectPromotionBySellerId(Integer sellerId) throws InterruptedException {
	    @SuppressWarnings("unchecked")
	    List<YmtSellerPromotion>  promotions = manage.getSelectResults(
	            "com.ymttest.database.mapping.YmtSellerPromotionMapper.selectPromotionBySellerId", sellerId);
	    manage.commit();
	    return promotions;
	}
	
	/*
	 * 根据买手ID获取促销活动ID
	 */
	public List<YmtSellerPromotion> selectPromotionByPromotionState(Integer sellerId) throws InterruptedException {
	    @SuppressWarnings("unchecked")
	    List<YmtSellerPromotion>  promotions = manage.getSelectResults(
	            "com.ymttest.database.mapping.YmtSellerPromotionMapper.selectPromotionBySellerId", sellerId);
	    manage.commit();
	    return promotions;
	}
	public List<YmtSellerPromotion> selectPromotionState(Integer sellerId) throws InterruptedException {
	    @SuppressWarnings("unchecked")
	    List<YmtSellerPromotion>  promotions = manage.getSelectResults(
	            "com.ymttest.database.mapping.YmtSellerPromotionMapper.selectPromotionState", sellerId);
	    manage.commit();
	    return promotions;
	}
	
	public int updateStateByPromotionId(Integer promotionId,String promotionBeginTime) throws InterruptedException {
		@SuppressWarnings("unchecked")
		Map a = new HashedMap();
		a.put("promotionId", promotionId);
		a.put("promotionBeginTime", promotionBeginTime);
		int b =  manage.update( "com.ymttest.database.mapping.YmtSellerPromotionMapper.updateStateByPromotionId",a);
		return b;
	}
	

	public static void main(String[] args) throws InterruptedException {

	}

}
